//
//
#ifndef Ray2D_h__
#define Ray2D_h__

#include "Point2D.h"
#include "Vector2D.h"

namespace Geometric
{
	class _GEOMETRIC Ray2D
	{
	public:
		// base point
		Point2D m_point;
		// vector
		Vector2D m_vector;

	public:
		Ray2D(const Point2D& _point, double _dir_x, double _dir_y)
			: m_point(_point), m_vector(_dir_x, _dir_y)
		{
		}

		Ray2D(const Ray2D& _ray) :m_point(_ray.m_point), m_vector(_ray.m_vector)
		{
		}

		~Ray2D()
		{
		}

	public:
		inline Ray2D& operator = (const Ray2D& _ray)
		{
			m_point = _ray.m_point;
			m_vector = _ray.m_vector;
			return (*this);
		}

	public:
		inline bool isZeroVector()
		{
			return m_vector.isZeroVector();
		}

		inline bool isBasePoint(double _x, double _y)
		{
			return m_point.isOverlap(_x, _y);
		}

		inline double getCross(double _dir_x, double _dir_y)
		{
			return m_vector.getCross(_dir_x, _dir_y);
		}

		inline bool isParallel(double _dir_x, double _dir_y)
		{
			return m_vector.isParallel(_dir_x, _dir_y);
		}

		inline bool isParallel(const Ray2D& _ray)
		{
			return m_vector.isParallel(_ray.m_vector.m_dir_x, _ray.m_vector.m_dir_y);
		}

		inline bool isPointOnRay(double _x, double _y)
		{
			double cross = getCross(_x - m_point.m_x, _y - m_point.m_y);
			return Gmath::isEqual(cross, 0);
		}

		inline bool isPointOnRay(const Point2D& _point)
		{
			return isPointOnRay(_point.m_x, _point.m_y);
		}

		inline bool isOverlap(const Ray2D& _ray)
		{
			return (isParallel(_ray) && _ray.m_point == m_point);
		}

		inline bool isSameDirection(double _dir_x, double _dir_y)
		{
			return m_vector.isSameDirection(_dir_x, _dir_y);
		}

		inline bool isSameDirection(const Ray2D& _ray)
		{
			return isSameDirection(_ray.m_vector.m_dir_x, _ray.m_vector.m_dir_y);
		}
	};


}

#endif